package com.wenchao.libtts;

import androidx.lifecycle.LifecycleService;
import androidx.lifecycle.Observer;

/**
 * @author super
 */
public class SpeechService extends LifecycleService {

    @Override
    public void onCreate() {
        super.onCreate();
        TextToSpeechPlayer.getInstance().init(this);
        LiveDataBus.getInstance()
                .with(EventBus.TTS_CONTENT, String.class)
                .observe(this, (Observer<String>) event ->
                        TextToSpeechPlayer.getInstance().speak(event));
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        TextToSpeechPlayer.getInstance().destroyTTS(this);
    }
}
